import { request } from 'umi';

/** 查询商城装饰(500500006) */
export async function getMallDecorate() {
  return request(`/api/mail/decorate`, {
    method: 'GET',
    headers: {
      Action_Id: '500500006'
    }
  });
}

/** 添加装饰(500500008) */
export async function uploadMallDecorate(data: any) {
  return request(`/api/mail/decorate`, {
    method: 'POST',
    data,
    headers: {
      Action_Id: '500500008'
    }
  });
}

/** 查询商城信息(500500000) */
export async function getMallInfo() {
  return request(`/api/mail/info`, {
    method: 'GET',
    headers: {
      Action_Id: '500500000'
    }
  });
}

/** 发布商城介绍信息(500500002) */
export async function postMallInfo(data: MALLAPI.MallInfo) {
  return request(`/api/mail/info`, {
    method: 'POST',
    data,
    headers: {
      Action_Id: '500500002'
    }
  });
}

/** 查询商城公告信息 */
export async function getMallNotice() {
  return request(`/api/mail/notice/1/limit/1`, {
    method: 'GET'
  });
}

/** 发布公告(500500005) */
export async function postMallNotice(data: MALLAPI.NoticeItem) {
  return request(`/api/mail/notice`, {
    method: 'POST',
    data,
    headers: {
      Action_Id: '500500005'
    }
  });
}

/** 查询导航列表(500501000) */
export async function getNavbarList() {
  return request(`/api/mail/navbar/1/limit/10000`, {
    method: 'GET',
    headers: {
      Action_Id: '500501000'
    }
  });
}

/** 添加/更新导航栏(500501001,500501004) */
export async function postNavbar(data: MALLAPI.NavbarItem, isUpdate: boolean) {
  return request(`/api/mail/navbar`, {
    method: 'POST',
    data,
    headers: {
      Action_Id: isUpdate ? '500501004' : '500501001'
    }
  });
}

/** 查看导航拦详情(500501003) */
export async function getNavbarDetail(id: string) {
  return request(`/api/mail/navbar/${id}`, {
    method: 'GET',
    headers: {
      Action_Id: '500501003'
    }
  });
}

/** 删除指定导航栏(500501005) */
export async function deleteNavbar(id?: string) {
  return request(`/api/mail/navbar/${id}`, {
    method: 'DELETE',
    headers: {
      Action_Id: '500501005'
    }
  });
}

/** 批量修改排序（需要全量传入，排序需要连续且不可重复）(500501002) */
export async function adjustNavSort(data: {navbar_list: {navbar_id?: string; sort?: number}[]}) {
  return request(`/api/mail/navbar/sort`, {
    method: 'PATCH',
    data,
    headers: {
      Action_Id: '500501002'
    }
  });
}

/** 查询商城启用模块 */
export async function getMallTag() {
  return request(`/api/mail/tag`, {
    method: 'GET'
  });
}

/** 查询店铺商品列表 */
export async function getShopGoodsByNavbar(data: any) {
  return request(`/api/mail/shop/goods/${data.current}/limit/${data.pageSize}`, {
    method: 'POST',
    data: {
      navbar_id: data.navbar_id
    }
  });
}